package com.csit.dao.impl;

import java.util.Date;

import org.hibernate.Query;
import org.springframework.stereotype.Repository;
import org.springframework.util.Assert;

import com.csit.dao.BuyDao;
import com.csit.entity.Buy;
import com.csit.entity.DataDictionary;

@Repository
public class BuyDaoImpl extends BaseDaoImpl<Buy, Integer> implements BuyDao {

	public Long getCount(DataDictionary shop) {
		Assert.notNull(shop, "Shop is required");
		String hql = "select count(*) from Buy where shop=:shop and createDate=:createDate";
		Query query = getSession().createQuery(hql);
		query.setEntity("shop", shop);
		query.setDate("createDate", new Date());
		Long count = (Long) query.uniqueResult();
		return count==null?0L:count;
	}
	
}
